<?php
if(isset($_GET["action"])) //check if the request exists
	{
	switch($_GET["action"]) //verify what kind of request is it
		{
		case "delete": //the request is an add request
			//perform task
			
			//getting the cart id from the cookie
			$shoppingcart_id = $_COOKIE["shoppingcart_id"];

			//getting the item id from the request
			$item_id = $_GET["item"];
		
			//perform the mysql query to link the two elements inside DB
			mysql_query("DELETE FROM rel WHERE ID_CART = '$shoppingcart_id' AND ID_ITEM = '$item_id'");
		break;
		
		case "update": //the request is an update request
			//perform tasl
			
			//getting the cart id from the cookie
			$shoppingcart_id = $_COOKIE["shoppingcart_id"];
			
			//getting the item id from the request
			$item_id = $_GET["item"];
			
			//getting the new quantity inserted in the textarea
			$new_quantity = $_GET["quantity"];
			
			//perform the mysql update
			mysql_query("UPDATE rel SET AMOUNT = '$new_quantity' WHERE ID_CART = '$shoppingcart_id' AND ID_ITEM = '$item_id'");
		break;
		}
	}
?>